
package com.eyedog.video.splash;

import com.eyedog.library.mvp.BasePresenter;
import com.eyedog.video.entity.SplashEntity;
import com.eyedog.video.http.ICallback;
import com.eyedog.video.splash.constract.IADVModel;
import com.eyedog.video.splash.constract.IADVPresenter;
import com.eyedog.video.splash.constract.IADView;

public class ADVPresenter extends BasePresenter<IADView, IADVModel> implements IADVPresenter {

    private boolean mIsFirstGuide = false;

    private int defaultPosition = 0;

    public ADVPresenter(IADView iadView, IADVModel iadvModel) {
        super(iadView, iadvModel);
    }

    @Override
    public void startSplash() {
        mIsFirstGuide = false;
        model.isFirstGuide(new constract.GuideCallback() {
            @Override
            public void isFirstGuide(boolean isFirstGuide) {
                mIsFirstGuide = isFirstGuide;
                if (mIsFirstGuide) {
                    model.loadFirstSplash(advCallback);
                } else {
                    model.loadSplash(advCallback);
                }
            }
        });
    }


    ICallback<SplashEntity> advCallback = new ICallback<SplashEntity>() {
        @Override
        public void onLoadSuccess(SplashEntity splashEntity) {
            if (splashEntity != null) {
                view.showSplashView(splashEntity);
            } else {
                view.showFailedView();
            }
        }

        @Override
        public void onLoadFailed(String err) {
            view.showFailedView();
        }
    };
}
